home *** CD-ROM | disk | FTP | other *** search
- /* Functions for accessing the preferences file.
- 93/12/16 aih created */
-
- #include "ApplicationLib.h"
- #include "FileLib.h"
- #include "FinderLib.h"
- #include "PreferencesLib.h"
- #include "ResourceConstantsLib.h"
- #include "ResourceLib.h"
-
- static FileRefType gPrefsReference = FILE_CLOSED;
-
- FileType *PrefsFile(void)
- {
- volatile FileRefType ref = FILE_CLOSED;
- static Boolean initialized;
- static FileType file;
- FileNameType name;
-
- TRY {
- if (! initialized) {
- ResStrLen(RLS_FILE, RLS_FILE_PREFERENCES, name, sizeof(FileNameType));
- FileSetPref(&file, name);
- if (! FileExists(&file)) {
- FileCreate(&file, AppCreator(), 'PREF');
- ResFileCreate(&file);
- ref = ResFileOpen(&file, fsWrPerm);
- FinderWriteDefaultMessage(RLS_FINDER_PREFS);
- ResFileClose(ref);
- ref = FILE_CLOSED;
- }
- initialized = true;
- }
- } CATCH {
- ResFileClose(ref);
- } ENDTRY;
- return(&file);
- }
-
- short PrefsReferenceNumber(void)
- {
- return(gPrefsReference);
- }
-
- void PrefsOpen(void)
- {
- require(gPrefsReference == FILE_CLOSED);
- gPrefsReference = ResFileOpen(PrefsFile(), fsCurPerm);
- }
-
- void PrefsClose(void)
- {
- ResFileClose(gPrefsReference);
- gPrefsReference = FILE_CLOSED;
- }
-